package com.example.back.jpa;

import java.util.Date;
import java.util.List;

import com.example.common.entity.PlantOrder;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.javers.spring.annotation.JaversSpringDataAuditable;

@JaversSpringDataAuditable
public interface PlantOrderRepository extends JpaRepository<PlantOrder,Long>{
    @Query(value = "select * from doctor_plant_order where dc_id_bigint = :dcId and time_type_tinyint = :timeType and plant_time_date = :day", nativeQuery = true)
    List<PlantOrder> getDocPlant(@Param("dcId") long DCID, @Param("timeType")  byte timeType, @Param("day")  Date day);
    
    @Query(value = "select * from doctor_plant_order where dc_id_bigint in (:dcId) and time_type_tinyint in (:timeType) and plant_time_date >= :beg and plant_time_date <= :end and disable_bit = 0",nativeQuery = true)
    List<PlantOrder> findAllByDcIdAndTimeType(@Param("dcId") List<Long> dcId, @Param("timeType")  List<Byte> timeType, @Param("beg") Date beg, @Param("end") Date end);
}
